package com.three.herler;

import org.springframework.dao.QueryTimeoutException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @author 袁大毛
 * * @date 2024/10/29 下午2:08
 * @描述
 */
//@ControllerAdvice// 全局异常处理
public class MyExceptionHandler {
    // 捕获异常
    //标记异常种类，遇见该类异常才会处理
    @ExceptionHandler(RuntimeException.class)
    public String handleException(RuntimeException e) {
        //System.out.println(e.getMessage());
        return "redirect:/error.jsp";
    }
    @ExceptionHandler(NullPointerException.class)
    public String handleException2(NullPointerException e) {
        //System.out.println(e.getMessage());
        return "redirect:/error.jsp";
    }
    @ExceptionHandler(QueryTimeoutException.class)
    public String handleException3(QueryTimeoutException e) {
        //System.out.println(e.getMessage());
        return "redirect:/error.jsp";
    }
    @ExceptionHandler(Exception.class)
    public String handleException4(Exception e) {
        //System.out.println(e.getMessage());
        return "redirect:/error.jsp";
    }
}